import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

Vue.use(VueRouter)




const router = new VueRouter({
  routes
})

// 通过路由导航守卫 控制页面访问权限
router.beforeEach((to, from, next) => {
  if (to.path === '/login') return next()
  var tokenStr = sessionStorage.getItem("token_key")
  if (!tokenStr) {
    next('/login')
  }
  next()
})

export default router